<?php

namespace App\Admin\Controllers;

use App\Admin\Repositories\Admin;
use Dcat\Admin\Form;
use Dcat\Admin\Grid;
use Dcat\Admin\Show;
//use Dcat\Admin\Controllers\AdminController;

class AdminController extends AdminController
{
    /**
     * Make a grid builder.
     *
     * @return Grid
     */
    protected function grid()
    {
        return Grid::make(new Admin(), function (Grid $grid) {
            $grid->admin_id->sortable();
            $grid->username;
            $grid->pwd;
            $grid->group_id;
            $grid->email;
            $grid->realname;
            $grid->tel;
            $grid->ip;
            $grid->add_time;
            $grid->mdemail;
            $grid->is_open;
            $grid->avatar;
            $grid->uid;
        
            $grid->filter(function (Grid\Filter $filter) {
                $filter->equal('admin_id');
        
            });
        });
    }

    /**
     * Make a show builder.
     *
     * @param mixed $id
     *
     * @return Show
     */
    protected function detail($id)
    {
        return Show::make($id, new Admin(), function (Show $show) {
            $show->admin_id;
            $show->username;
            $show->pwd;
            $show->group_id;
            $show->email;
            $show->realname;
            $show->tel;
            $show->ip;
            $show->add_time;
            $show->mdemail;
            $show->is_open;
            $show->avatar;
            $show->uid;
        });
    }

    /**
     * Make a form builder.
     *
     * @return Form
     */
    protected function form()
    {
        return Form::make(new Admin(), function (Form $form) {
            $form->display('admin_id');
            $form->text('username');
            $form->text('pwd');
            $form->text('group_id');
            $form->text('email');
            $form->text('realname');
            $form->text('tel');
            $form->text('ip');
            $form->text('add_time');
            $form->text('mdemail');
            $form->text('is_open');
            $form->text('avatar');
            $form->text('uid');
        });
    }
}
